package com.lcf.framework.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 描述：路径工具类
 *
 * @author lcf
 * @since 2025/2/25 15:12
 */
public class UrlUtils {
    /**
     * 判断路径是否在匹配列表
     */
    public static boolean matchUrl(List<String> urls, String path) {
        if (CollectionUtils.isEmpty(urls) || StringUtils.isBlank(path)) {
            return false;
        }

        AntPathMatcher matcher = new AntPathMatcher();

        return urls.stream().anyMatch(pattern -> matcher.match(pattern, path));
    }
}
